package fr.utbm.aiechat.packets;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.SocketException;

public class ChannelObjRequestPacket
{
	private DatagramPacket packet;
	
	public ChannelObjRequestPacket(InetAddress Address, int Port, int uniqueId) throws SocketException
	{
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		DataOutputStream data = new DataOutputStream(stream);
		
		try
		{
			// The PacketType
			data.writeInt(Packets.CHANOBJ_REQUEST);
			
			// uniqueId of channel request
			data.writeInt(uniqueId);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		packet = new DatagramPacket(stream.toByteArray(), stream.size(), Address, Port);
	}
	
	public DatagramPacket getPacket()
	{
		return packet;
	}
}
